package com.imis.module.api.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.imis.module.base.BaseController;
import com.imis.module.api.model.ro.SysDictItemsByCodeQueryRO;
import com.imis.module.api.model.ro.SysDictItemsQueryRO;
import com.imis.base.globle.Result;
import com.imis.module.api.bus.DropDownBoxBus;
import com.imis.module.system.model.ro.QueryDictTreeRO;
import com.imis.module.system.model.vo.DictVO;
import com.imis.module.system.model.vo.DropDownBoxTreeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * DropDownBoxController<br>
 * 下拉框接口相关 前端控制器
 * </p>
 *
 * @author XinLau
 * @version 1.0
 * @since 2020年05月29日 10:39
 */
@Slf4j
@RestController
@RequestMapping("/sys/selectBox")
@Api(tags = {"下拉接口"})
@ApiSort(3)
public class DropDownBoxController extends BaseController<DropDownBoxBus> {

    @RequestMapping(value = "/queryDictItemsByDictCode", method = RequestMethod.GET)
    @ApiOperation(value = "根据字典编码（code）获取下拉", notes = "根据字典编码（code）获取下拉")
    @ApiImplicitParam(name = "dictCode", value = "字典编码（code）", dataType = "String", dataTypeClass = String.class, required = true)
    @ApiOperationSupport(order = 1, author = "XinLau")
    public Result<List<DictVO>> queryDictItemsByDictCode(@RequestParam(name = "dictCode", required = true) String dictCode) {
        return service.queryDictItemsByDictCode(dictCode);
    }

    @RequestMapping(value = "/queryTableDictItemsByParameter", method = RequestMethod.POST)
    @ApiOperation(value = "查询指定表、字段的下拉", notes = "通过查询指定表（table）的 字段（text、code）进行条件SQL语句（filterSql）检索查询数据成为字典结果")
    @ApiOperationSupport(order = 2, author = "XinLau")
    public Result<List<DictVO>> queryTableDictItemsByParameter(@RequestBody @Valid SysDictItemsQueryRO sysDictItemsQuery) {
        return service.queryTableDictItemsByParameter(sysDictItemsQuery);
    }

    @RequestMapping(value = "/queryTableDictItemsByCode", method = RequestMethod.POST)
    @ApiOperation(value = "查询指定表、字段的指定内容（code）的下拉", notes = "通过查询指定表（table）的 字段（text、code）进行指定内容（code）的检索查询数据成为字典结果")
    @ApiOperationSupport(order = 3, author = "XinLau")
    public Result<List<DictVO>> queryTableDictItemsByCode(@RequestBody @Valid SysDictItemsByCodeQueryRO sysDictItemsByCodeQuery) {
        return service.queryTableDictItemsByCode(sysDictItemsByCodeQuery);
    }

    @RequestMapping(value = "/queryOrganizationTreeByName", method = RequestMethod.GET)
    @ApiOperation(value = "根据组织机构名称获取下拉", notes = "根据组织机构名称获取下拉")
    @ApiImplicitParam(name = "organizationName", value = "组织机构名称", dataType = "String", dataTypeClass = String.class, required = false)
    @ApiOperationSupport(order = 4, author = "XinLau")
    public Result<List<DropDownBoxTreeVO>> queryOrganizationTreeByOrganizationName(@RequestParam(name = "organizationName", required = false) String organizationName) {
        return service.queryOrganizationTreeByOrganizationName(organizationName);
    }

    @RequestMapping(value = "/queryMenuTreeByMenuName", method = RequestMethod.GET)
    @ApiOperation(value = "根据功能菜单名称获取下拉", notes = "根据功能菜单名称获取下拉")
    @ApiImplicitParam(name = "menuName", value = "功能菜单名称", dataType = "String", dataTypeClass = String.class, required = false)
    @ApiOperationSupport(order = 5, author = "XinLau")
    public Result<List<DropDownBoxTreeVO>> queryMenuTreeByMenuName(@RequestParam(name = "menuName", required = false) String menuName) {
        return service.queryMenuTreeByMenuName(menuName);
    }

    @RequestMapping(value = "/queryDictTreeListByParameter", method = RequestMethod.POST)
    @ApiOperation(value = "条件查询字典树下拉", notes = "条件查询字典树下拉")
    @ApiOperationSupport(order = 6, author = "XinLau")
    public Result<List<DropDownBoxTreeVO>> queryDictTreeListByParameter(@RequestBody QueryDictTreeRO queryDictTree) {
        return service.queryDictTreeListByParameter(queryDictTree);
    }

    @RequestMapping(value = "/queryQuartzJobClassName", method = RequestMethod.GET)
    @ApiOperation(value = "获取定时任务的Class类名", notes = "获取定时任务的Class类名")
    @ApiOperationSupport(order = 7, author = "XinLau")
    public Result queryQuartzJobClassName(){
        return service.queryQuartzJobClassName();
    }

    @RequestMapping(value = "/queryQuartzJobParameterName", method = RequestMethod.GET)
    @ApiOperation(value = "获取定时任务Class类的参数信息", notes = "获取定时任务Class类的参数信息")
    @ApiImplicitParam(name = "className", value = "定时任务Class类名", dataType = "String", dataTypeClass = String.class, required = true)
    @ApiOperationSupport(order = 8, author = "XinLau")
    public Result queryQuartzJobParameterName(@RequestParam(name = "className", required = true) String className){
        return service.queryQuartzJobParameterName(className);
    }

    @RequestMapping(value = "/queryPermissionsValueConstantField", method = RequestMethod.GET)
    @ApiOperation(value = "获取请求权限常量类内的常量", notes = "获取请求权限常量类内的常量")
    @ApiImplicitParam(name = "modeName", value = "模块名关键字", dataType = "String", dataTypeClass = String.class, required = false)
    @ApiOperationSupport(order = 9, author = "XinLau")
    public Result queryPermissionsValueConstantField(@RequestParam(name = "modeName", required = false) String modeName){
        return service.queryPermissionsValueConstantField(modeName);
    }

    @RequestMapping(value = "/queryDictCodeConstantField", method = RequestMethod.GET)
    @ApiOperation(value = "获取DictCode常量", notes = "获取DictCode常量")
    @ApiOperationSupport(order = 10, author = "XinLau")
    public Result queryDictCodeConstantField(){
        return service.queryDictCodeConstantField();
    }

    // 查询所有用户  作为字典信息 username -->value,realname -->text

}
